using UnityEngine;
using System;

namespace ZCTouchDrawBoard
{
    [Serializable]
    public class PaintAttribute
    {
        #region PublicField
        /// <summary>
        /// 纯颜色 or 贴纸 or mask+背景贴纸
        /// </summary>
        public ePaintType PaintType = ePaintType.Color;

        /// <summary>
        /// 缩略图路径
        /// </summary>
        public string IconPath = null;

        /// <summary>
        /// 素材路径
        /// </summary>
        public string MaterialPath
        {
            get
            {
                if (MaterialPaths == null)
                {
                    return null;
                }
                return MaterialPaths[0];
            }
            set
            {
                if (MaterialPaths == null)
                {
                    MaterialPaths = new string[1];
                }
                MaterialPaths[0] = value;
            }
        }

        /// <summary>
        /// 多个素材
        /// </summary>
        public string[] MaterialPaths = null;

        /// <summary>
        /// 颜色
        /// </summary>
        public Color PenColor = Color.white;

        /// <summary>
        /// 是否能够更改颜色
        /// </summary>
        public bool IsChangeColor = false;

        /// <summary>
        /// 大小
        /// </summary>
        public float PenSize = 1.0f;

        /// <summary>
        /// 线条间隔
        /// </summary>
        public float LineSpace = 0.0f;

        /// <summary>
        /// 线条长度
        /// </summary>
        public float LineLength = 0.0f;

        /// <summary>
        /// 贴纸数量
        /// </summary>
        public int StickerCount
        {
            get
            {
                if (MaterialPaths == null) 
                {
                    return 0;
                }
                return MaterialPaths.Length;
            }
            private set { }
        }
        #endregion

        #region PublicMethod
        public PaintAttribute() { }

        public void Copy(PaintAttribute paintAttribute)
        {
            if (paintAttribute == null)
            {
                Logger.e("paint attribute copy is null.");
                return;
            }
            PaintType = paintAttribute.PaintType;
            IconPath = paintAttribute.IconPath;
            PenColor = paintAttribute.PenColor;
            IsChangeColor = paintAttribute.IsChangeColor;
            PenSize = paintAttribute.PenSize;
            LineSpace = paintAttribute.LineSpace;
            LineLength = paintAttribute.LineLength;
            MaterialPaths = paintAttribute.MaterialPaths;
        }

        public PaintAttribute Clone()
        {
            PaintAttribute paintAttribute = new PaintAttribute();
            paintAttribute.Copy(this);
            return paintAttribute;
        }
        #endregion
    }

}
